﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master_form.master" AutoEventWireup="true" CodeFile="dm_xet_hoc_bong.aspx.cs" Inherits="App_Form_DaoTao_dm_xet_hoc_bong" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">

        Ext.require([
        'Ext.selection.CellModel',
        'Ext.grid.*',
        'Ext.data.*',
        'Ext.util.*',
        'Ext.state.*',
        'Ext.form.*',
        'Ext.grid.Panel'
        ]);

        Ext.onReady(function () {

            Ext.QuickTips.init();

            var bd = Ext.getBody();

            var gridForm = Ext.create('Ext.form.Panel', {
                id: 'company-form',
                frame: true,
                bodyPadding: 5,
                layout: {
                    type: 'column',
                    columns: 1
                },
                fieldDefaults: {
                    labelAlign: 'left',
                    msgTarget: 'side'
                },

                items: [
                    {
                        columnWidth: '40%',
                        margin: '0 0 0 10',
                        xtype: 'fieldset',
                        title: 'Thông tin chính',
                        defaults: {
                            width: 350,
                            labelWidth: 90
                        },
                        defaultType: 'textfield',
                        items: [{
                            fieldLabel: 'Năm học',
                            xtype: 'combo',
                            value: 'I',
                            emptyText: 'Chọn năm học',
                            triggerAction: 'all',
                            forceSelection: true,
                            editable: false,
                            id: 'nam_hoc',
                            name: 'nam_hoc',
                            displayField: 'ten',
                            valueField: 'id',
                            queryMode: 'local',
                            store: null,
                            listeners: {
                                select: function (combo, record, index) {
                                    if (record.length > 0) {
                                        var id_hb = record[0].get('id');
                                        //Goi service
                                        wdkhp.Fs_XET_HB_LKE(id_hb, xet_hb_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                    }
                                }
                            }
                        },
                        {
                            xtype: 'combo',
                            fieldLabel: 'Loại',
                            value: '',
                            triggerAction: 'all',
                            emptyText: 'Chọn loại',
                            forceSelection: true,
                            editable: false,
                            id: 'loai',
                            name: 'loai',
                            displayField: 'Ten',
                            valueField: 'ID',
                            queryMode: 'local',
                            store: null
                        }
                        , {
                            fieldLabel: 'Chuyên môn',
                            xtype: 'numberfield',
                            hideTrigger: true,
                            id: 'cm',
                            name: 'cm'
                        },
                        {
                            fieldLabel: 'Môn khác',
                            xtype: 'numberfield',
                            hideTrigger: true,
                            id: 'khac',
                            name: 'khac'
                        },
                        {
                            fieldLabel: 'Rèn luyện',
                            xtype: 'numberfield',
                            hideTrigger: true,
                            id: 'RL',
                            name: 'RL'
                        },
                        {
                            fieldLabel: 'Số tiền',
                            xtype: 'numberfield',
                            id: 'tien',
                            name: 'tien'
                        }
                        ,
                        {
                            xtype: 'fieldcontainer',
                            combineErrors: true,
                            layout: {
                                type: 'hbox',
                                defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                            },
                            items: [
                                {
                                    name: 'add',
                                    xtype: 'button',
                                    width: 90,
                                    icon: '../../shared/icons/fam/add.gif',
                                    text: 'Thêm mới',
                                    handler: function () {
                                        var form = this.up('form').getForm();
                                        if (form.isValid()) {
                                            var b_nam = Ext.getCmp('nam_hoc').getValue(),
                                              b_dk = Ext.getCmp('DK').getValue(),
                                            b_gchu = Ext.getCmp('Gchu').getValue();
                                            if (b_nam == "") { return alert("Chưa chọn năm"); }
                                            if (b_dk == "") { return alert("Chưa nhập điều kiện xét"); }

                                            wdkhp.Fs_XET_HB_NH(b_nam, b_dk, b_gchu, P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
                                        }
                                    }
                                },
                                {
                                    name: 'moi',
                                    xtype: 'button',
                                    width: 90,
                                    icon: '../../shared/icons/fam/delete.gif',
                                    text: 'Xóa',
                                    handler: function () {
                                        var c = confirm("Bạn có chắc chắn xóa không ?"); if (!c) return;
                                        var b_nam = Ext.getCmp('nam_hoc').getValue();
                                        if (b_nam == "") { return alert("Chưa chọn năm"); }

                                        wdkhp.Fs_XET_HB_XOA(b_nam, P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
                                    }
                                }
                            ]
                        }
                        ]
                    }
                ],
                renderTo: bd
            });
            wdkhp.Fs_TT_CHUNG(P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        function P_LOAD_TTCHUNG(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            var a_kq = b_kq.split('@');
            var b_chuoi1 = CH_JSON(a_kq[0]);
            var b_chuoi2 = CH_JSON(a_kq[1]);

            var a_data5 = Ext.create('Ext.data.Store', {
                fields: ['id', 'ten'],
                data: b_chuoi1
            });
            var a_data6 = Ext.create('Ext.data.Store', {
                fields: ['ID', 'Ten'],
                data: b_chuoi2
            });
            var cd = Ext.getCmp('nam_hoc');
            cd.bindStore(a_data5);

            var ds = Ext.getCmp('loai');
            ds.bindStore(a_data6);
        }
        function xet_hb_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            if (b_kq == "[]") {
                Ext.getCmp('DK').setValue("");
                Ext.getCmp('Gchu').setValue("");
                return;
            }
            var b_chuoi1 = CH_JSON(b_kq);
            var a_data5 = Ext.create('Ext.data.Store', {
                fields: ['DK', 'Gchu'],
                data: b_chuoi1
            });

            var form = Ext.getCmp('company-form');
            form.getForm().loadRecord(a_data5.data.items[0]);
        }
    </script>
</asp:Content>

